import type { PageParams } from '@/types/gobal'
import type { OrderCreateParams, OrderListResult, OrderPreResult, OrderResult } from '@/types/order'
import { http } from '@/utils/http'
/*  GET/member/order/pre
 填写订单-获取预付订单 */
export const getMemberOrderPreAPI = () => {
  return http<OrderPreResult>({
    method: 'GET',
    url: '/member/order/pre',
  })
}
/* 填写订单-获取立即购买订单
GET/member/order/pre/now
*/
export const getMemberOrderPreNowAPI = (data: {
  skuId: string
  count: string
  addressId?: string
}) => {
  return http<OrderPreResult>({
    method: 'GET',
    url: '/member/order/pre/now',
    data,
  })
}
/* 提交订单
POST/member/order */
export const postMemberOrderAPI = (data: OrderCreateParams) => {
  return http<{ id: string }>({
    method: 'POST',
    url: '/member/order',
    data,
  })
}
/* 获取订单详情
GET/member/order/{id} */
export const getMemberOrderAPI = (id: string) => {
  return http<OrderResult>({
    method: 'GET',
    url: `/member/order/${id}`,
  })
}
/* 获取订单列表
GET/member/order */
export const getMemberOrderListAPI = (data: PageParams) => {
  return http<OrderListResult>({
    method: 'GET',
    url: '/member/order',
    data,
  })
}
